//面包屑
// new Vue().$mount('#crumbs');

var msgId = localStorage.getItem("sendedMsgId");
console.log("msgId:" + msgId);
var sm = new Vue({
    el: "#messagedetail",
    data: function () {
        return {
            tableData: [],
            visible: true,
            msgtitle: '',
            sendtime: '',
            dept: '',
            sender: '',
            msgcontent: '',
            receivers: ''
        }
    },
    methods: {
        getData: function () {
            VanyAjax("/sendedmsg/getMsgDetail", {msgId: msgId}, "GET").done(function (data) {
                console.log(data);
                this.msgtitle = data.msgtitle;
                this.sendtime = new Date(data.sendTime).Format("yyyy-MM-dd hh:mm:ss")
                this.msgcontent = data.msgContent;
                var receivers = eval('(' + data.receivers + ')');
                var names = "接收人（共" + receivers.length + "人）:";
                var name = "";
                for (var j = 0; j < receivers.length; j++) {
                    if (j == 0) {
                        name = receivers[j].name;
                    } else {
                        name = name + "," + receivers[j].name;
                    }
                }
                this.receivers = names + name;
                VanyAjax('/base/user/getUserByUserId', {userId: data.senderId}, 'GET').done(function (data) {
                    console.log(data);
                    this.sender = data.userName;
                    this.dept = data.dept;
                }, false, this)
            }, false, this);
        },
        msgStatistic: function(){
            $("#content").load("templates/authority/sendedMessage/html/messageStatistics.html");
        }
    },
    mounted: function () {
        console.log("hello");
        this.getData();
    }
})
Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};